<template>
	<!-- 核保处理-列表页面 -->
	<div class="fillcontain" height="800vh">
		<el-form label-width="100px" class="search_container">
			<el-row class="mt10">
				<el-col :span="6">
					<el-form-item label="受理号：" prop="applnum">
						<el-input v-model="searchParams.applnum" @blur="chearTrim" placeholder="受理号" clearable>
						</el-input>
					</el-form-item>
				</el-col>
				<el-col :span="6">
					<el-form-item label="保单号：" prop="caseno">
						<el-input v-model="searchParams.chdrnum" @blur="chearTrim" placeholder="保单号" clearable>
						</el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12" class="pl20">
					<el-button type="primary" icon="el-icon-search" @click="goForceData"></el-button>
					<el-button type="primary" plain icon="el-icon-refresh" @click="resetSearch"></el-button>
				</el-col>
			</el-row>
		</el-form>
		<div class="contain">
			<div class="table_container">
			</div>
		</div>
	</div>
</template>

<script>
	import {
		mapState,
		mapGetters
	} from 'vuex';
	import uwconstant from '@/utils/uwConstants';
	import constant from '@/utils/constant';
	import {
		isCntainChinese,
	} from "@/api/refund/RefundCommon";
	import {
		createFile
	} from "@/api/setting/maintain";
	export default {
		data() {
			return {
				searchParams: {
					applnum: '',
					chdrnum: ''
				},
				loading: false,

			}
		},
		created() {},
		mounted() {

		},
		methods: {
			chearTrim() {
				this.searchParams.applnum = this.searchParams.applnum.trim();
				this.searchParams.chdrnum = this.searchParams.chdrnum.trim();
			},
			goForceData() {
				if (this.searchParams.applnum == "" && this.searchParams.chdrnum == "") {
					this.$message.error("请至少输入一个查询条件！");
					return;
				}
				if (this.searchParams.applnum != "") {
					if (isCntainChinese(this.searchParams.caseno)) {
						this.$message.error("请正确输入受理号！");
						return;
					}
				}
				this.canGoForceData();
			},
			 canGoForceData() {
				 this.$store.dispatch('loading/CHANGE_LOADING', true);
				 createFile(this.searchParams).then(res => {
					if (res.resultCode == constant.SUCCESS ) {
						this.$message.success(res.resultMsg);
					} 
					this.$store.dispatch('loading/CHANGE_LOADING', false)
				}).catch(err =>{
					this.$store.dispatch('loading/CHANGE_LOADING', false)
				})
			},
			// 清除查询条件
			resetSearch() {
				this.searchParams.caseno = '';
				this.searchParams.chdrnum = '';

			},
			keyEvent() {
				var e = event || window.event;
				if (e && e.keyCode == 113) {
					this.goHeBao();
				}
			},
		},
		computed: {
			...mapGetters(['tags']),
			reload() {
				return this.$store.state.loading.reload;
			}
		},

		activated() {
			if (this.reload) {
				this.$store.dispatch('loading/CHNAGE_RELOAD', false)
				Object.assign(this.$data, this.$options.data());
			}

			//监听F2 按键事件
			document.addEventListener('keydown', this.keyEvent);
		},
		beforeRouteLeave(to, from, next) {
			document.removeEventListener('keydown', this.keyEvent)
			next();
		},
	}
</script>

<style lang="less" scoped>
	.fillcontain {
		padding-bottom: 0;
	}

	.contain {
		background: #fff;
		padding: 10px;
		margin-bottom: 20px;
	}

	.pagination {
		padding: 10px 20px;
		text-align: right;
	}

	.operationIcon {
		// padding: 12px;
		border: 1px solid #e5e5e5;
		border-radius: 50%;
		width: 22px;
		height: 22px;
		display: inline-block;
		cursor: pointer;
		box-shadow: 0 0 3px #f9f9f9;

		.svg-icon {
			font-size: 14px;
			fill: #68a3fc;
		}
	}

	.search_container {
		padding: 20px 20px 0 20px;
	}
</style>
